import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import pinia from './store'
import directive from './directive/index'
import emitter from '@/utils/mitt'
import loading from '@/views/custom-plugins/loading'
import i18nPlugin from './plugins/i18n'
import elementPlus from './plugins/elementPlus'

import '@/styles/index.css'

const app = createApp(App)
// UI
app.use(elementPlus)
// 指令
app.use(directive)
// store
app.use(pinia)
// 路由
app.use(router)
// 国际化
app.use(i18nPlugin, {
	greetings: {
		hello: 'Bonjour!',
	},
})
// FIXME 添加自定义插件
app.use(loading, { color: '#fff' })

// TODO 添加全局属性,
// vue2  vue.prototype.$timer = function()()
app.config.globalProperties.$timer = function () {
	return new Date()
}
// 可选添加类型推断, 代码 在 shims-vue.d
app.config.globalProperties.$bus = emitter

// TODO 全局异常处理
app.config.errorHandler = (err, vm, info) => {
	console.log('[全局异常]', err, vm, info)
}
app.mount('#app')
